import React from "react";
import ReactDom from "react-dom";
import {createStore, applyMiddleware, compose} from "redux";
import thunk from "redux-thunk";
import {Provider} from "react-redux";
import {BrowserRouter, Switch, Route} from "react-router-dom";
/*
* 导入axios拦截配置
* */
import "./config";
import reducer from "./reducer";

/*路由组件*/
import Auth from "./component/auth/auth";
import Register from "./container/register/register";
import Login from "./container/login/login";
import BossInfo from "./container/bossinfo/bossinfo";
import GeniusInfo from "./container/geniusinfo/geniusinfo";
import Chat from "./container/chat/chat";
import DashBoard from "./container/dash-board/dash-board";
import "./index.scss";

const store = createStore(reducer, compose(
  applyMiddleware(thunk),
  window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__() : f => f
));

ReactDom.render(
  (
    <Provider store={store}>
      <BrowserRouter>
        <div>
          <Auth/>
          <Switch>
            <Route path="/register" component={Register}/>
            <Route path="/login" component={Login}/>
            <Route path="/bossinfo" component={BossInfo}/>
            <Route path="/geniusinfo" component={GeniusInfo}/>
            <Route path="/chat/:userId" component={Chat}/>
            <Route component={DashBoard}/>
          </Switch>
        </div>
      </BrowserRouter>
    </Provider>

  ), document.getElementById("root"));
